
import user from '@/store/modules/user';
<template>
    <div class="box">
      <h2>Son2 子组件</h2>
      从vuex中获取的值:<label>{{ count }}</label>
      <br />
      <button @click="add (1)">值 - 1</button>
      <button @click="changeAfter('修改成功')">修改一秒后</button>
      <div>{{ user.name }}</div>
      <div>{{ user.like }}</div>
      <div>{{ changeList }}</div>
      <button @click="changeName">修改名字</button>
    </div>
  </template>

<script>
import { mapActions, mapGetters, mapMutations, mapState } from 'vuex'
// import { mapState } from 'vuex'
export default {
  name: 'Son2Com',
  computed: {
    count () {
      return this.$store.state.count
    },
    ...mapState('user', ['user', 'like']),
    ...mapGetters('user', ['changeList'])
  },
  methods: {
    ...mapMutations(['add'], 1),
    ...mapActions(['changeAfter'], '你好'),
    ...mapMutations('user', ['changeName'], 15)
  }
}
</script>

  <style lang="css" scoped>
  .box {
    border: 3px solid #ccc;
    width: 400px;
    padding: 10px;
    margin: 20px;
  }
  h2 {
    margin-top: 10px;
  }
  </style>
